package com.lonelylang.core.config;

import com.lonelylang.core.common.Properties;
import com.lonelylang.core.factory.DataProcessTemplate;
import com.lonelylang.core.log.LogStarter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@EnableConfigurationProperties(DataProcessProperties.class)
@Configuration
//@ConditionalOnProperty(prefix = "dataprocess",value = "enable") 加载本配置类得前提条件
public class DataProcessConfiguration {
    Logger logger= LoggerFactory.getLogger(DataProcessConfiguration.class);
    @Bean
    public DataProcessTemplate CoreStrategyFactory(DataProcessProperties dataProcessProperties){
        if(dataProcessProperties.isOpenProxy()){
            logger.info("dataprocess Open the agent mode");
            LogStarter.printLog("dataprocess Open the agent mode in this request");
        }else {
            logger.info("dataprocess  Agent mode is not enabled ");
            LogStarter.printLog(" Dataprocess agent mode is not enabled in this request  ");
        }
        if(null==dataProcessProperties.getDbpackage()){
            logger.info("The implementation class package path dbpackage of listening data table is not set");
            LogStarter.printLog("The implementation class package path dbpackage of listening data table is not set in this request");
        }
        Properties.IS_OPEN_PROXY= dataProcessProperties.isOpenProxy();

        Properties.EXECUTE_PACKAGE_PREFIX=dataProcessProperties.getDbpackage();

        return DataProcessTemplate.getInstance();
    }



}
